<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.sql.DataSource"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="com.mysql.jdbc.Driver"%>
<html>
<%

InitialContext initialContext = new InitialContext();

DataSource dataSource = (DataSource) initialContext.lookup("java:jdbc/MySqlDS");

Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();

ResultSet resultSet = statement.executeQuery("select * from employee");

if(resultSet!=null){
	%>
	<table border="1">
	<tr>
		<td>S.No</td>
		<td>FirstName</td>
		<td>LastName</td>
		<td>Email Id</td>
		<td>Mobile No</td>
		<td>DOB</td>
		<td>Delete</td>
	</tr>
	<%
	int i =0;
	String id;
	while(resultSet.next()){
		id = resultSet.getObject(1).toString();
		%>
		<tr>
			<td><%=id%></td>
			<td><%=resultSet.getObject(2).toString() %></td>
			<td><%=resultSet.getObject(3).toString() %></td>
			<td><%=resultSet.getObject(4).toString() %></td>
			<td><%=resultSet.getObject(5).toString() %></td>
			<td><%=resultSet.getObject(6).toString() %></td>
			<td><a href="delete.jsp?id=<%=id%>">delete</a></td>
		</tr>
		<%
	}
	%>
	</table>
<%	
}
resultSet.close();
statement.close();
connection.close();
%>
<body>

</body>
</html>
